﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;


namespace FAP.DataAccess.BLL
{
    public class nghiepvu
    {
        public int id { get; set; }
        public string tennghiepvu { get; set; }
        public bool isdeleted { get; set; }
        //public List<chitietnghiepvu> chitietnghiepvus { get { return chitietnghiepvu.chitietnghiepvuSelectRowByForeignKey_nghiepvuid(id); } }

        #region nghiepvuSelectAll
        public static List<nghiepvu> nghiepvuSelectAll()
        {
            IDataReader dr = FAP.DataAccess.DAL.nghiepvuSelectAll();
            List<nghiepvu> nghiepvuList = new List<nghiepvu>();
            while (dr.Read())
            {
                nghiepvu mynghiepvu = new nghiepvu
                {
                    id = !dr.IsDBNull(dr.GetOrdinal("id")) ? (int)dr["id"] : 0,
                    tennghiepvu = !dr.IsDBNull(dr.GetOrdinal("tennghiepvu")) ? (string)dr["tennghiepvu"] : null,
                    isdeleted = !dr.IsDBNull(dr.GetOrdinal("isdeleted")) ? (bool)dr["isdeleted"] : false
                };
                nghiepvuList.Add(mynghiepvu);
            }
            dr.Close();
            dr.Dispose();
            return nghiepvuList;
        }
        #endregion

        #region nghiepvuSelectRow
        public static nghiepvu nghiepvuSelectRow(int id)
        {
            IDataReader dr = FAP.DataAccess.DAL.nghiepvuSelectRow(id);
            nghiepvu nghiepvu = null;

            if (dr.Read())
            {
                nghiepvu = new nghiepvu
                {
                    id = !dr.IsDBNull(dr.GetOrdinal("id")) ? (int)dr["id"] : 0,
                    tennghiepvu = !dr.IsDBNull(dr.GetOrdinal("tennghiepvu")) ? (string)dr["tennghiepvu"] : null,
                    isdeleted = !dr.IsDBNull(dr.GetOrdinal("isdeleted")) ? (bool)dr["isdeleted"] : false,

                };
            }
            dr.Close();
            dr.Dispose();
            return nghiepvu;
        }
        #endregion

        #region nghiepvuInsertRow
        public static void nghiepvuInsertRow(int id, string tennghiepvu, bool isdeleted)
        {
            FAP.DataAccess.DAL.nghiepvuInsertRow(id, tennghiepvu, isdeleted);
        }
        #endregion

        #region nghiepvuUpdateRow
        public static void nghiepvuUpdateRow(int id, string tennghiepvu, bool isdeleted)
        {
            FAP.DataAccess.DAL.nghiepvuUpdateRow(id, tennghiepvu, isdeleted);
        }
        #endregion

        #region nghiepvuDeleteRow
        public static void nghiepvuDeleteRow(int id)
        {
            FAP.DataAccess.DAL.nghiepvuDeleteRow(id);
        }
        #endregion
    }
}